/*
 * @Author: Li Zengkun
 * @Date: 2022-09-26 16:59:16
 * @LastEditors: Li Zengkun
 * @LastEditTime: 2022-09-29 17:40:58
 * @Description: 
 */
import { defineStore } from "pinia"
import { admin } from "@/api"

export const useUserStore = defineStore('user', {
    state: () => {
        return {
            data: {},
        }
    },
    actions: {
        setUser(value) {
            this.data = value
        },
        async loadProfile(id) {
            try {
                let { status, data } = await admin.info({ id })
                if (status) {
                    console.log(data);
                    this.data = data
                }
            } catch (error) {
                console.log(error);
            }

        },
        updateUser(value) {
            for (let key in value) {
                this.data[key] = value[key]
            }
        }
    }
})